package com.example.timecalculous;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

public class MyAdapter extends BaseAdapter {
    public LayoutInflater inflater;
    private Cursor mCursor;

    public MyAdapter(Context context, Cursor cursor){
        mCursor = cursor;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return mCursor.getCount();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        convertView=inflater.inflate(R.layout.listview,null);
        TextView txt1=(TextView)convertView.findViewById(R.id.txt1);
        TextView txt2=(TextView)convertView.findViewById(R.id.txt2);
        ToggleButton toggleButton= (ToggleButton) convertView.findViewById(R.id.btnn3);
        mCursor.moveToPosition(position);
        txt1.setText(mCursor.getString(4)+":"+mCursor.getString(5)+"~"+
                mCursor.getString(6)+":"+mCursor.getString(7));
        txt2.setText(mCursor.getString(8));
        toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            }
        });
        return convertView;
    }
}
